﻿
--[[
    @brief    ui logic for lol_repair ui
    @author   dragonqiu
    @version  1.0
    @date     2015-03-25
--]]

repair_model = 
{
    game_misc = nil;
    -- tgp route地址
    tgp_web_url = "";
    wegame_repair_url_head = LoadStr("TOOLBOX_HEAD_URL");
    dnf_repair_url_head = LoadStr("DNF_REPAIR_HEAD_URL"); --临时复用以前的页面
    init = function()
        if repair_model.tgp_web_url == nil or repair_model.tgp_web_url == "" then
            repair_model.get_web_url();
        end
        repair_model.pageUrl = repair_model.wegame_repair_url_head.."repair_lol.html";

        -- body
        repair_model.game_misc =
            base_utility.get_component_adapter("ILOL_tools",
                "ierd_tgp.game_misc.GetLOLToolsModule();");
    end;

     get_web_url = function()
        local game_lib =
            base_utility.get_component_adapter("IGame_library",
                "ierd_tgp.game_library.Get_game_library_adapter();");
        local common_info = ierd_tgp.game_library.Common_info_export:new_local();
        game_lib:get_common_info(common_info);
        -- 得到tgp route地址
        local tool_box_url = common_info.tool_box_url;
        local last_index = repair_model._find_last(tool_box_url, "/");
        if last_index ~= nil then
            tool_box_url = string.sub(tool_box_url, 1, last_index);
        end;
        repair_model.tgp_web_url = tool_box_url;
        return tool_box_url;
    end;

    _find_last  = function(haystack, needle)
        local i = haystack:match(".*"..needle.."()");
        if i == nil then 
            return nil;
        else 
            return i-1;
        end;
    end;
};

repair_model.init();
